package com.linkage.lcims.base.service.business.impl;

import java.util.List;

//import org.dom4j.Document;
import com.linkage.lcims.base.dao.business.interfaces.TollAttrPolicyDAO;
import com.linkage.lcims.base.dao.business.interfaces.TollPolicyAttrDAO;
import com.linkage.lcims.base.dao.business.interfaces.TollPolicyDAO;
import com.linkage.lcims.base.dao.business.interfaces.TollPolicySuitDAO;
import com.linkage.lcims.base.memoryparam.interfaces.TollPolicyMP;
import com.linkage.lcims.base.po.business.BdTollPolicy;
import com.linkage.lcims.base.service.business.interfaces.TollPolicyBO;
import com.linkage.lcims.base.service.system.interfaces.AdminLogBO;
import com.linkage.util.exception.ServiceException;

public class TollPolicyBOImpl implements TollPolicyBO {

	private String message;
	
	private TollPolicyMP tollPolicyMP;
	
	private TollPolicyDAO tollPolicyDAO;
	private TollAttrPolicyDAO tollAttrPolicyDAO;
	private TollPolicyAttrDAO tollPolicyAttrDAO;
	private TollPolicySuitDAO tollPolicySuitDAO;
	
	private AdminLogBO adminLogBO;
	
	public TollPolicyBOImpl() {
		super();
	}

	public List<BdTollPolicy> getAllTollPolicy() throws ServiceException {
		try {
//			return tollPolicyDAO.getAll();
			return tollPolicyMP.getAll();
		} catch (Exception e) {
			throw new ServiceException(e, this.getClass());
		}
	}

	public List<BdTollPolicy> getTollPolicyByCondiction(BdTollPolicy tollPolicy) throws ServiceException {
		try {
			List<BdTollPolicy> tempList = tollPolicyDAO.getAll();
			int j = 0;
			for (int i = 0; i < tempList.size(); i++) {
				BdTollPolicy tempTollPolicy = tempList.get(i);
				boolean flag = true;
				if (tollPolicy.getPolicyid() != null) {
					if ( !(tollPolicy.getPolicyid().equals(tempTollPolicy.getPolicyid()))) {
						flag = false;
					}
				}
				if (flag&&tollPolicy.getPolicyname() != null) {
					if ( !(tollPolicy.getPolicyname().equals(tempTollPolicy.getPolicyname()))) {
						flag = false;
					}
				}
				if (flag&&tollPolicy.getDescription() != null) {
					if ( !(tollPolicy.getDescription().equals(tempTollPolicy.getDescription()))) {
						flag = false;
					}
				}
				if (flag == false) {
					tempList.remove(j);
				}else{
					j++;
				}
			}
			return tempList;
		} catch (Exception e) {
			throw new ServiceException(e, this.getClass());
		}
	}
	
//	public Document getTollPolicyDocument(BdTollPolicy tollPolicy) throws ServiceException {
//		try {
////			XmlOperater oper = new XmlOperater();
////			
////			BdTollPolicy tempPolicy = tollPolicyDAO.getTollPolicy(tollPolicy);
////			Document doc = oper.generateComplexXMLFromObj(tempPolicy, BdTollPolicy.class, tempPolicy.getPolicyid());
////			
////			ArrayList tollAttrPolicyList = (ArrayList)tollAttrPolicyDAO.getTollAttrPolicyList(tollPolicy);
////			for (int i = 0; i < tollAttrPolicyList.size(); i++) {
////				BdTollAttrPolicy tollAttrPolicy = (BdTollAttrPolicy)tollAttrPolicyList.get(i);
////				Document doc1 = oper.generateComplexXMLFromObj(tollAttrPolicy, BdTollAttrPolicy.class,tollAttrPolicy.getComp_id());
////				
////				ArrayList tollPolicyAttrList = (ArrayList)tollPolicyAttrDAO.getTollPolicyAttrList(tollAttrPolicy);
////				for (int j = 0; j < tollPolicyAttrList.size(); j++) {
////					BdTollPolicyAttr tollPolicyAttr = (BdTollPolicyAttr)tollPolicyAttrList.get(j);
////					Document doc2 = oper.generateComplexXMLFromObj(tollPolicyAttr, BdTollPolicyAttr.class, tollPolicyAttr.getComp_id());
////					doc1.getRootElement().add(doc2.getRootElement());
////				}
////				
////				ArrayList tollPolicySuitList = (ArrayList)tollPolicySuitDAO.getTollPolicySuitList(tollAttrPolicy);
////				for (int k = 0; k < tollPolicySuitList.size(); k++) {
////					BdTollPolicySuit tollPolicySuit = (BdTollPolicySuit)tollPolicySuitList.get(k);
////					Document doc3 = oper.generateComplexXMLFromObj(tollPolicySuit, BdTollPolicySuit.class, tollPolicySuit.getComp_id());
////					doc1.getRootElement().add(doc3.getRootElement());
////				}
////				
////				doc.getRootElement().add(doc1.getRootElement());
////			}			
////			
////			return doc;
//			return null;
//		} catch (Exception e) {
//			throw new ServiceException(e, this.getClass());
//		}
//	}
	
	
	public String getMessage() {
		// TODO Auto-generated method stub
		return message;
	}

	public AdminLogBO getAdminLogBO() {
		return adminLogBO;
	}

	public void setAdminLogBO(AdminLogBO adminLogBO) {
		this.adminLogBO = adminLogBO;
	}

	public TollAttrPolicyDAO getTollAttrPolicyDAO() {
		return tollAttrPolicyDAO;
	}

	public void setTollAttrPolicyDAO(TollAttrPolicyDAO tollAttrPolicyDAO) {
		this.tollAttrPolicyDAO = tollAttrPolicyDAO;
	}

	public TollPolicyAttrDAO getTollPolicyAttrDAO() {
		return tollPolicyAttrDAO;
	}

	public void setTollPolicyAttrDAO(TollPolicyAttrDAO tollPolicyAttrDAO) {
		this.tollPolicyAttrDAO = tollPolicyAttrDAO;
	}

	public TollPolicyDAO getTollPolicyDAO() {
		return tollPolicyDAO;
	}

	public void setTollPolicyDAO(TollPolicyDAO tollPolicyDAO) {
		this.tollPolicyDAO = tollPolicyDAO;
	}

	public TollPolicySuitDAO getTollPolicySuitDAO() {
		return tollPolicySuitDAO;
	}

	public void setTollPolicySuitDAO(TollPolicySuitDAO tollPolicySuitDAO) {
		this.tollPolicySuitDAO = tollPolicySuitDAO;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public TollPolicyMP getTollPolicyMP() {
		return tollPolicyMP;
	}

	public void setTollPolicyMP(TollPolicyMP tollPolicyMP) {
		this.tollPolicyMP = tollPolicyMP;
	}


}
